<template>
	<view class="content">
		<view class="btn">
			<button type="default" @click="scan">扫描</button>
		</view>
		<view class="admin">
			<view>{{ msg }}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg: ''
			};
		},
		methods: {
			scan() {
				uni.scanCode({
					success: (res) => {
						console.log('条码类型：' + res.scanType);
						console.log('条码内容：' + res.result);
						this.msg = '条码内容：' + res.result;
					},
					fail: (err) => {
						console.error('扫码失败：', err);
					}
				});
			}
		}
	};
</script>